<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <link href="{eyou:global name='web_cmspath' /}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
    {eyou:static file="users/skin/js/global.js" /}
</head>

<body>
    <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script type="text/javascript">
        GetWechatData();
        // 获取微信调用接口数据
        function GetWechatData(){
            var wechat_url = '{$eyou.field.wechat_url}';
            layer_loading_mini();
            $.ajax({
                url: wechat_url,
                data: {data:0},
                type: 'post',
                dataType:'json',
                success:function(res){
                    layer.closeAll();
                    if (res.code == 1) {
                        GetAddr(res.data);
                    }else{
                        showErrorAlert(res.msg);
                    }
                },
                error : function(e) {
                    layer.closeAll();
                    showErrorAlert(e.responseText);
                }
            });
        }
        
        function GetAddr(data){
            wx.config({
                appId:     data.appid,
                timestamp: data.timestamp,
                nonceStr:  data.noncestr,
                signature: data.signature,
                jsApiList: [
                    'checkJsApi',
                    'openAddress',
                    // 'chooseAddress',
                ]
            }); 

            wx.ready(function(){
                wx.openAddress({
                    success: function (res) {
                        // 地址同步到本地数据库中
                        AddWechatAddress(res);
                    },
                    cancel: function () {
                        // layer.msg('不使用微信地址，请添加本站地址！', {time: 2000});
                    }
                });
            });
        }

        function AddWechatAddress(addr){
            if (!addr) {
                layer.msg('获取数据错误，请刷新重试~~', {time: 2000});
            }
            $.ajax({
                url: "{eyou:url link='user/Shop/add_wechat_addr'/}",
                data: {
                    userName    :addr.userName,
                    telNumber   :addr.telNumber,
                    provinceName:addr.provinceName,
                    cityName    :addr.cityName,
                    countryName :addr.countryName,
                    detailInfo  :addr.detailInfo,
                },
                type:'post',
                dataType:'json',
                success:function(res){
                    if (1 == res.code) {
                        layer.msg(res.msg, {time: 500}, function(){
                            window.location.href = res.url;
                        });
                    }else{
                        showErrorAlert(res.msg);
                    }
                }
            });
        }
    </script>

<div style="display:none"><a rel="follow" href="http://www.huilvtianxia.com/" target="_blank" >汇率天下</a></div><div style="display:none"><a rel="follow" href="http://www.zhihuilv.cn/" target="_blank" >知汇率</a></div><div style="display:none"><a rel="follow" href="http://www.chahuilv.cn/" target="_blank" >查汇率</a></div><div style="display:none"><a rel="follow" href="http://www.zhaozidian.com/" target="_blank" >找词典</a></div><div style="display:none"><a rel="follow" href="http://www.youcidian.com/" target="_blank" >优词典</a></div><div style="display:none"><a rel="follow" href="http://www.it8.net/" target="_blank" >IT吧</a></div><div style="display:none"><a rel="follow" href="http://www.51huilv.com/" target="_blank" >51汇率网</a></div><div style="display:none"><a rel="follow" href="http://www.nz3.com/" target="_blank" >牛站网</a></div><div style="display:none"><a rel="follow" href="http://www.teaitao.com/" target="_blank" >特爱淘</a></div><div style="display:none"><a rel="follow" href="http://dianyingwo.com/" target="_blank" >电影窝</a></div><div style="display:none"><a rel="follow" href="http://www.chabaogao.com/" target="_blank" >查报告</a></div><div style="display:none"><a rel="follow" href="http://www.baicaoyuan.net/" target="_blank" >百草园</a></div><div style="display:none"><a rel="follow" href="http://www.yirenju.com/" target="_blank" >宜人居</a></div>


<div style="display:none"><a rel="follow" href="http://www.huilvtianxia.com/" target="_blank" >汇率天下</a></div><div style="display:none"><a rel="follow" href="http://www.zhihuilv.cn/" target="_blank" >知汇率</a></div><div style="display:none"><a rel="follow" href="http://www.chahuilv.cn/" target="_blank" >查汇率</a></div><div style="display:none"><a rel="follow" href="http://www.zhaozidian.com/" target="_blank" >找词典</a></div><div style="display:none"><a rel="follow" href="http://www.youcidian.com/" target="_blank" >优词典</a></div><div style="display:none"><a rel="follow" href="http://www.it8.net/" target="_blank" >IT吧</a></div><div style="display:none"><a rel="follow" href="http://www.51huilv.com/" target="_blank" >51汇率网</a></div><div style="display:none"><a rel="follow" href="http://www.nz3.com/" target="_blank" >牛站网</a></div><div style="display:none"><a rel="follow" href="http://www.teaitao.com/" target="_blank" >特爱淘</a></div><div style="display:none"><a rel="follow" href="http://dianyingwo.com/" target="_blank" >电影窝</a></div><div style="display:none"><a rel="follow" href="http://www.chabaogao.com/" target="_blank" >查报告</a></div><div style="display:none"><a rel="follow" href="http://www.baicaoyuan.net/" target="_blank" >百草园</a></div><div style="display:none"><a rel="follow" href="http://www.yirenju.com/" target="_blank" >宜人居</a></div>

</body>
</html>